Skip to content

fix(DataList): Padding on first column and alignment for headers#3277

Merged
codecademydev merged 17 commits intomainfrom
kl-gmt-1544-datalist-th-td-padding
Mar 19, 2026
Merged

fix(DataList): Padding on first column and alignment for headers#3277
codecademydev merged 17 commits intomainfrom
kl-gmt-1544-datalist-th-td-padding

Conversation

@LinKCoding
Copy link
Contributor

@LinKCoding LinKCoding commented Mar 3, 2026

Overview

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GMT-1544 GMT-1573
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Don't make me tap the sign.

  1. Go to DataList
  2. Look like the "Non-selectable rows" section and verify that the "Rank" header and the column's text are all aligned correctly (i.e. have the same padding) — optionally check against prod where there is extra 8 padding on the column's text
  3. Inspect the header and see that only the first element gets the pl: 8 and the last element gets pr:8 (this can be done on one or many DataList)
  4. Scan through the other examples and see that the columns all align properly — optionally check against prod examples too
  5. Shrink the screen size to check against mobile sizes and check alignments
  6. Check DataTable too and see that they all look the same as prod
  7. Repeat for List
  8. ...
  9. Finish and do a celebratory dance

PR Links and Envs

Repository PR Link
Mono Mono PR

@nx-cloud
Copy link

nx-cloud bot commented Mar 3, 2026

View your CI Pipeline Execution ↗ for commit d261d0c


☁️ Nx Cloud last updated this comment at 2026-03-19 14:30:31 UTC

@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.12%. Comparing base (c849ff9) to head (d261d0c).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3277      +/-   ##
==========================================
- Coverage   89.77%   89.12%   -0.65%     
==========================================
  Files         362      236     -126     
  Lines        5231     4342     -889     
  Branches     1696     1478     -218     
==========================================
- Hits         4696     3870     -826     
+ Misses        525      463      -62     
+ Partials       10        9       -1     
Flag Coverage Δ
main ?
pull-request 89.12% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

: sortDirection === 'asc'
? 'ascending'
: 'descending';
{selectable && (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the fragment b.c. it was interfering with the addition of data-first-col for the first element in the TableHeader
Also doesn't seem necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not using data-*-col approach anymore, so re-adding is fine, but it's also not necessary from what I can tell

@LinKCoding LinKCoding changed the title starting point fix(DataList): Padding on first column and alignment for headers Mar 4, 2026
@LinKCoding LinKCoding marked this pull request as ready for review March 6, 2026 20:53
@LinKCoding LinKCoding requested a review from a team as a code owner March 6, 2026 20:53
@LinKCoding LinKCoding requested review from jakemhiller and sh0ji March 6, 2026 20:53
Comment on lines +1 to +4
import { Children, cloneElement, isValidElement, ReactNode } from 'react';

/**
* Marks the first and last columns with `data-first-col` / `data-last-col`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i really dislike cloning children, especially in a component like a DataList where we're already looping though all the columns to render them and there could be alot of them. maybe we you can move this logic into checking the idx of the React.Map in TableHeaderRow?

Copy link
Contributor Author

@LinKCoding LinKCoding Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I did try this approach and it worked well for TableHeaderRow!
But when I went to see how we could use it for List, I ran into an issue again where the children are pretty configurable - i.e. I couldn't just add to the children's attribute without some type of new iteration.

And then after trying another approach with setting context and passing on the idx, the robot confirmed my suspicion that it's just as expensive as cloning.

So instead, I went back to the drawing board and realized that if we can't add padding to the children, maybe we can do that for the parent (row) instead. Since we only want either the first td or th — which seems like it'd translate to just the px of the row itself.

Looks like this works, and I've cleaned up some code that tries to be selective about what child gets padding. But yea, would compare against DataList, DataTable, and List.

@LinKCoding LinKCoding requested a review from dreamwasp March 16, 2026 15:41
Copy link
Contributor

@dreamwasp dreamwasp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! if you have time could you remove the red BG on this List example? ik it is unrelated and literally probably something i did

Image i

@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@codecademy/gamut@68.1.4-alpha.554975.0
@codecademy/gamut-kit@0.6.589-alpha.554975.0
@codecademy/styleguide@79.2.2-alpha.554975.0

@github-actions
Copy link
Contributor

@LinKCoding LinKCoding added the Ship It :shipit: Automerge this PR when possible label Mar 19, 2026
@codecademydev codecademydev merged commit 1b55acd into main Mar 19, 2026
23 of 24 checks passed
@codecademydev codecademydev removed the Ship It :shipit: Automerge this PR when possible label Mar 19, 2026
@codecademydev codecademydev deleted the kl-gmt-1544-datalist-th-td-padding branch March 19, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants